#include "text.h"
#include <cstring>

Text::Text() 
{ }

Text::Text(Sprite* pS)
{	
    pSprite = pS;
}

void Text::Present(int n, float posX, float posY, float scale, int transparent)
{	
    int index = 0;
    do
    {	
        index = (n % 10) + 26;
        n /= 10;
        pSprite->SetPosition(posX, posY);
        pSprite->Draw(index, scale, transparent);
        posX -= (35 * scale);
    } while (n != 0);
    return;
}

void Text::Present(char* s, float posX, float posY, float scale, int transparent)
{	
    int index = 0;
    for (int i = strlen(s) - 1; i >= 0; --i)
    {	
        if (s[i] >= 'a') 
            index = (s[i] - 'a') % 26;
        else if (s[i] >= 'A')
            index = (s[i] - 'A') % 26;
        else if (s[i] >= '0')
            index = (s[i] - '0') % 36;
        else
            index = 36;   
        pSprite->SetPosition(posX, posY);
        pSprite->Draw(index, scale, transparent);
        posX -= (35 * scale);
    }
    return;
}
